//
//  CategoryView.m
//  JinMaJiaDemo
//
//  Created by GripMeMory on 15/9/8.
//  Copyright (c) 2015年 GripMeMory. All rights reserved.
//

#import "CategoryView.h"

@implementation CategoryView

#pragma mark - Initialization Method

- (instancetype)init{
    self = [super init];
    if (self) {
        self.item = [[CategoryItem alloc] init];
        self.tapAction = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(Click:)];
        [self addGestureRecognizer:self.tapAction];
    }
    return self;
}

- (void)layoutSubviews
{
    self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 99, 20)];
    self.titleLabel.backgroundColor = [UIColor orangeColor];
    [self addSubview:self.titleLabel];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.mas_bottom).with.offset(-3);
        make.centerX.equalTo(self.mas_centerX);
    }];
    
    self.tapAction = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(Click:)];
    [self addGestureRecognizer:self.tapAction];
    
    self.titleLabel.text = _item.itemName;
    self.titleLabel.textAlignment = NSTextAlignmentCenter;
    
}

#pragma mark -Tap Action
- (void)Click:(UITapGestureRecognizer *)tap{
    if ([tap.view isKindOfClass:[CategoryView class]]) {
        CategoryView *tapedView = (CategoryView *)tap.view;
    }
}

@end
